using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;
public abstract class IEnemy : IAttrEnemy
{
    public bool Die = false;
    public float distance;
   public AudioSource audioSource;
   
    protected void Init()

    {
        audioSource = GetComponent<AudioSource>();
        if (audioSource.volume!=0)
        audioSource.volume = GameFacade.Instance.volume+0.5f;
       
        GameFacade.Instance.characterSystem.AddEnemy(this);
        mSystem = new EnemyFSMSystem();
        mAnimator = transform.GetComponent<Animator>();
        IEnemyFSM enemyidle = new Enemyidel(mSystem, this);
        enemyidle.AddTransition(e_Enemystate.SeeEnemy, e_EnemystateId.Chase);
        IEnemyFSM enemychas = new EnemyChase(mSystem, this);
        enemychas.AddTransition(e_Enemystate.CanAttack, e_EnemystateId.Attack);
        enemychas.AddTransition(e_Enemystate.NoEnemy, e_EnemystateId.Idle);
        IEnemyFSM enemyattack = new EnemyAttack(mSystem, this);
        enemyattack.AddTransition(e_Enemystate.SeeEnemy, e_EnemystateId.Chase);
        mSystem.AddState(enemyidle);
        mSystem.AddState(enemyattack);
        mSystem.AddState(enemychas);
        mAgent = transform.GetComponent<NavMeshAgent>();
        if (audioSource.volume != 0)
            audioSource.volume = GameFacade.Instance.volume + 0.5f;
    }
    public abstract void GetHit(int damage);
    public abstract void InIdle();
    public abstract void UpdateIdle();
    public abstract void LeaveIdle();
    public abstract void InChase();
    public abstract void UpdateChase();
    public abstract void LeaveChase();
    public abstract void InAttack();
    public abstract void UpdateAttack();
    public abstract void LeaveAttack();
    public void UpdateDo()
    {
        mSystem.CurrentState.Update();
        if(GameFacade.Instance.characterSystem.player!=null)
        {
            distance = Vector3.Distance
                (transform.position, GameFacade.Instance.characterSystem.player.transform.position);
            
        }
    }
    public abstract void Attack();
}
